package com.xrf;

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Users {
    private int user;
    private int password;
    private Long entry;
    private Long resetting;
    
    private static List<Users> list = new ArrayList<>();
    private static Scanner scanner = new Scanner(System.in);
    
    public Users() {}
    
    public Users(int user, int password, Long entry, Long resetting) {
        this.user = user;
        this.password = password;
        this.entry = entry;
        this.resetting = resetting;
    }
    
    // Getter and Setter methods
    public int getUser() { return this.user; }
    public void setUser(int user) { this.user = user; }
    public int getPassword() { return this.password; }
    public void setPassword(int password) { this.password = password; }
    public Long getEntry() { return this.entry; }
    public void setEntry(Long entry) { this.entry = entry; }
    public Long getResetting() { return this.resetting; }
    public void setResetting(Long resetting) { this.resetting = resetting; }
    
    @Override
    public String toString() {
        StringBuilder builder = new StringBuilder();
        builder.append("用户:").append(user).append("\t");
        builder.append("密码:").append(password).append("\t");
        builder.append("登录:").append(entry).append("\t");
        builder.append("重置:").append(resetting).append("\t");
        return builder.toString();
    }
    
    // 数据操作方法
    public static void addData() {
        System.out.println("--------添加数据-------");
        System.out.println("请输入用户：");
        int user = scanner.nextInt();
        System.out.println("请输入密码：");
        int password = scanner.nextInt();
        System.out.println("请输入登录：");
        Long entry = scanner.nextLong();
        System.out.println("请输入重置：");
        Long resetting = scanner.nextLong();
        
        Users data = new Users(user, password, entry, resetting);
        list.add(data);
    }
    
    public static void removeData() {
        System.out.println("--------删除数据-------");
        System.out.println("请输入索引：");
        int index = scanner.nextInt();
        list.remove(index);
    }
    
    public static void updateData() {
        System.out.println("--------修改数据-------");
        System.out.println("请输入索引：");
        int index = scanner.nextInt();
        System.out.println("请输入用户：");
        int user = scanner.nextInt();
        System.out.println("请输入密码：");
        int password = scanner.nextInt();
        System.out.println("请输入登录：");
        Long entry = scanner.nextLong();
        System.out.println("请输入重置：");
        Long resetting = scanner.nextLong();
        
        Users data = new Users(user, password, entry, resetting);
        list.set(index, data);
    }
}